package com.hl.sfzy.controller;

import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.entity.ConsultAppointment;
import com.hl.sfzy.entity.User;
import com.hl.sfzy.service.ConsultAppointmentService;
import com.hl.sfzy.service.UserService;
import com.hl.sfzy.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName ConsultAppintmentController
 * @Description TODO
 * @Author Jerry
 * @Date 2024年01月15日 15:10
 * @Version 1.0
 */
@CrossOrigin
@RestController
@RequestMapping("/consultAppointment")
public class ConsultAppointmentController {
    @Autowired
    private ConsultAppointmentService ConsultAppointmentService;
    /**
     * 新增
     */
    @PostMapping("/add")
    public Result add(@RequestBody ConsultAppointment ConsultAppointment) throws Exception {
        ConsultAppointmentService.add(ConsultAppointment);
        return Result.success();
    }
    /**
     * 编辑
     */
    @PutMapping("/edit")
    public Result edit(@RequestBody ConsultAppointment ConsultAppointment) {
        ConsultAppointmentService.edit(ConsultAppointment);
        return Result.success();
    }
    /**
     * 删除
     */
    @DeleteMapping("/remove/{id}")
    public Result remove(@PathVariable Integer id) {
        ConsultAppointmentService.remove(id);
        return Result.success();
    }
    /**
     * 批量删除
     */
    @DeleteMapping("/remove")
    public Result removeBatch(Integer[] ids) {
        System.out.println(ids);
        ConsultAppointmentService.removeBatch(ids);
        return Result.success();
    }
    /**
     * 单条查询
     */
    @GetMapping("/find/{id}")
    public Result findById(@PathVariable Integer id) {
        return Result.success(ConsultAppointmentService.findById(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/find")
    public Result findPage(@RequestParam(value = CommonConstant.PAGE_NUM, required = false, defaultValue = CommonConstant.PAGE_NUM_DEFAULT) Integer pageNum,
                           @RequestParam(value = CommonConstant.PAGE_SIZE, required = false, defaultValue = CommonConstant.PAGE_SIZE_DEFAULT) Integer pageSize,
                           ConsultAppointment ConsultAppointment) {
        return Result.success(ConsultAppointmentService.findPage(pageNum, pageSize, ConsultAppointment));
    }
}
